# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=loadlibrary
pkgver=104.c40033b
pkgrel=1
pkgdesc='Porting Windows Dynamic Link Libraries to Linux.'
groups=('blackarch' 'blackarch-binary')
arch=('x86_64' 'aarch64')
url='https://github.com/taviso/loadlibrary'
license=('GPL2')
depends=('cabextract' 'readline' 'gcc' 'lib32-glibc' 'lib32-gcc-libs')
makedepends=('git')
source=("git+https://github.com/taviso/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  make
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/mpclient" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./mpclient "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/mpclient"
}

